package ru.ssau.berlin.framework.validate;


public class ValidatorFactory {

    private volatile static ValidatorFactory instance;

    private ValidatorFactory() {}

    public static ValidatorFactory getInstance() {
        if (instance == null) {
            synchronized (ValidatorFactory.class) {
                if (instance == null) {
                    instance = new ValidatorFactory();
                }
            }
        }
        return instance;
    }

    public TypeValidator getValidator(DataType type) {
//        String pattern;
        // FIX: write regexps for each type!
        switch (type) {
            case INT:
                return new IntegerValidator();
            case FLOAT:
                return new FloatValidator();
            case STRING:
                return new TrueValidator();
            case BOOLEAN:
                return new BooleanValidator();
            default:
                throw new IllegalArgumentException("such data type isn't supported yet");
        }
//        return new RegExpValidator(pattern);
    }
    
}
